﻿package com.plter.controls.asmax
{
	import flash.display.Shape;
	import flash.events.MouseEvent;
	
	/**
	 * 最大化图形
	 * @author Jaja as-max.cn
	 */
	internal class AMaxBox extends ASprite
	{
		private var isMaxMode:Boolean = false;
		
		private var maxBoxShape:Shape = new Shape;
		
		public function AMaxBox() :void
		{
			drawBG(18, 16, 0xF0F0F0, 0xDDDDDD, 5, 5);
			bgAlpha = 0.01;
			
			addChild(maxBoxShape);
			maxMode = false;
			
			this.addEventListener(MouseEvent.MOUSE_OVER, mouseEventHandler);
			this.addEventListener(MouseEvent.MOUSE_OUT, mouseEventHandler);
		}
		
		/**
		 * 指示是否为最大化的图形
		 */
		public function set maxMode(value:Boolean):void {
			isMaxMode = value;
			
			if (isMaxMode) {
				drawMaxBox();
			}else {
				drawNormalBox();
			}
		}
		/**
		 * 指示是否为最大化的图形
		 */
		public function get maxMode():Boolean {
			return isMaxMode;
		}
		
		private function drawMaxBox():void {
			maxBoxShape.graphics.clear();
			maxBoxShape.graphics.lineStyle(1.5, 0x000000);
			maxBoxShape.graphics.drawRect(6, 4, 8, 6);
			maxBoxShape.graphics.drawRect(3, 7, 8, 6);
		}
		
		private function drawNormalBox():void {
			maxBoxShape.graphics.clear();
			maxBoxShape.graphics.lineStyle(1.5, 0x000000);
			maxBoxShape.graphics.drawRect(3.5, 3.5, 11, 10);
		}
		
		private function mouseEventHandler(event:MouseEvent):void {
			switch(event.type) {
				case MouseEvent.MOUSE_OUT:
					bgAlpha = 0.01;
					break;
				case MouseEvent.MOUSE_OVER:
					bgAlpha = 1;
					break;
			}
		}
		
	}
	
}